package com.sfx.concurrent.demo.JVM.heap;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-01-30
 * Time: 16:33
 */
public class TestDemo1 {
    /**
     * java.lang.OutOfMemoryError: Java heap space 堆内存溢出错误
     * -Xmx8m(设置8兆)  虚拟机参数  设置堆内存空间的大小
     * @param args
     */
    public static void main(String[] args) {
        int i = 0;
        try{
            String s = "hello";
            List<String> res = new ArrayList<>();
            while(true) {
                res.add(s);
                s = s+ s;
                i++;
            }
        }catch (Throwable throwable) {
            System.out.println(i);
            throwable.printStackTrace();
        }
    }

}
